package com.gymjournal

import org.junit.Test

import static junit.framework.Assert.assertTrue
import static junit.framework.Assert.assertFalse
import static junit.framework.Assert.assertNotNull

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
class GymnasticTests {

    @Test
    void testSave() {
        def oneSet = new GymSet(numberOfIteration: 8, operatingWeight: 50)
        def gymnasticType = new GymnasticType(code: "gym", displayName: "Gym!")
        def gymnastic = new Gymnastic()

        assertTrue gymnastic.validate(["note"])

        assertTrue gymnastic.validate(["gymSets"])
        gymnastic.addToGymSets(oneSet)
        assertTrue gymnastic.validate(["gymSets"])

        assertFalse gymnastic.validate()

        gymnastic.gymnasticType = gymnasticType
        assertTrue gymnastic.validate()

        gymnastic.customGymnasticType = "GYM"
        assertFalse gymnastic.validate()

        gymnastic.gymnasticType = null
        assertTrue gymnastic.validate()

        assertNotNull gymnastic.save()
    }
}
